package ABC.AAA;


import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.net.http.HttpResponse;
import java.util.Arrays;

@Controller
public class register {

    @RequestMapping(value = "/")
    public String HH(){
        return "register";
    }
//    @RequestMapping(value = "/user/reg",method = RequestMethod.POST)
    public String registerrr(HttpServletRequest request, HttpServletResponse response, HttpSession session){
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String sex = request.getParameter("sex");
        String[] hobby = request.getParameterValues("hobby");
        String intro = request.getParameter("intro");
        System.out.println(username);
        System.out.println(password);
        System.out.println(sex);
        System.out.println(Arrays.toString(hobby));
        int i;
        for ( i=0;i<hobby.length;i++){
            System.out.println(hobby[i]);
        }
        System.out.println(intro);


        return "ok";
    }

//    @RequestMapping(value = "/user/regg",method = RequestMethod.POST)

    public String getUser(
         // @RequestParam(value ="username")
            String username,
          //  @RequestParam(value ="password")
            String password,
          //  @RequestParam(value ="sex")
            Integer sex,
           // @RequestParam(value ="hobby")
            String[] hobby,
         //   @RequestParam(value ="intro")
            String intro,
          //  @RequestParam(name ="age",required = false)
            Integer age

    ){
        System.out.println(username);
        System.out.println(password);
        System.out.println(sex);
        System.out.println(Arrays.toString(hobby));
        System.out.println(intro);
        System.out.println(age);
        return  "ok";
    }


    @RequestMapping(value = "haha",method = RequestMethod.POST)
    public String hahha(User user,
                        @RequestHeader(value="Sec-Fetch-Destttt", required = false, defaultValue = "xswl")
             String referer,
                        @CookieValue(value ="id", required = false,defaultValue = "xswl")
                        String id){
        System.out.println(user);
        System.out.println(referer);
        System.out.println(id);
        return "ok";
    }
}

